const mongoose = require('mongoose');
const Schema = mongoose.Schema;
let ObjectId = Schema.Types.ObjectId;

// 创建goodsschema
const goodsSchema = new Schema({
  id: {type: ObjectId},//商品id
  no: {unique: true,type: String},//商品编号
  name: {type: String},//商品名
  category: {type: ObjectId, ref: 'Category'},//类别
  size: String,//尺寸
  texture: String,//材质
  factory: {type: ObjectId,ref: 'Factory'},//厂家
  picId: [{type: ObjectId, ref: 'TempPic'}],//图片
  feed: [Schema.Types.Mixed],//加料
  price: Number,//售价
  inPrice: Number,//进价
  remark: String,//备注
  style: {type: ObjectId,ref: 'Style'},//风格
  desciption: String,//描述
  status: {type: Number, default: 200},
  saleAmt: {type: Number, default: 0},
  saleStatus: {type: String, default: 'onsale'},
  createAt: {type: Date, default: Date.now},//生成时间
})

mongoose.model('Goods',goodsSchema);
